package com.sfy.course.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sfy.course.dataObject.Course;
import com.sfy.course.mapper.CourseMapper;
import com.sfy.course.service.CourseService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * (Course)表服务实现类
 *
 * @author makejava
 * @since 2024-09-11 20:54:46
 */
@Service("courseService")
public class CourseServiceImpl extends ServiceImpl<CourseMapper,Course> implements CourseService{
    @Resource
    private CourseMapper courseDao;

    /**
     * 通过ID查询单条数据
     *
     * @param courseId 主键
     * @return 实例对象
     */
    @Override
    public Course queryById(Integer courseId) {
        return this.courseDao.queryById(courseId);
    }

    /**
     * 新增数据
     *
     * @param course 实例对象
     * @return 实例对象
     */
    @Override
    public Course insert(Course course) {
        this.courseDao.insert(course);
        return course;
    }

    /**
     * 修改数据
     *
     * @param course 实例对象
     * @return 实例对象
     */
    @Override
    public Course update(Course course) {
        this.courseDao.update(course);
        return this.queryById(course.getCourseId());
    }

    /**
     * 通过主键删除数据
     *
     * @param courseId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer courseId) {
        return this.courseDao.deleteById(courseId) > 0;
    }
}
